package com.ssy.lingxi.purchase.api.enums.purchase;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 采购询价单工作流外部状态枚举
 *  0.已完成 1.待提交需求单 2.待审核需求单 3.待提交报价单 4.待确认授标结果 5.审核不通过需求单
 * @author wrc
 * @date 2021/1/19
 */
public enum PurchaseInquiryListExternalWorkStateEnum {
    CANCEL(-1, "已作废"),
    COMPLETE(99, "已完成"),
    STAY_SUBMIT_REQUIREMENTS(1, "待提交采购需求单"),
   // STAY_AUDIT_REQUIREMENTS(2, "待审核采购需求单"), 21.1.20版本去掉
    STAY_SUBMIT_OFFER(3, "待提交报价单"),
    STAY_CONFIRMATION_OF_AWARD(4, "待确认授标结果"),
    AUDIT_NOT_REQUIREMENTS(5, "采购需求单审核不通过"),
    LAUNCH_NEXT_TURN(6, "发起下轮报价"),
    ;

    private Integer state;
    private String name;

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public String getName() {
        return LanguageHolder.getName(this.getClass(), this.state);
    }

    public void setName(String name) {
        this.name = name;
    }

    PurchaseInquiryListExternalWorkStateEnum(Integer state, String name) {
        this.state = state;
        this.name = name;
    }

    public static String getName(Integer state){
        PurchaseInquiryListExternalWorkStateEnum workEnum = Arrays.stream(PurchaseInquiryListExternalWorkStateEnum.values()).filter(v -> v.getState().equals(state)).findAny().orElse(null);
        return null == workEnum ? "" : LanguageHolder.getName(PurchaseInquiryListExternalWorkStateEnum.class, workEnum.getState());
    }
}
